home *** CD-ROM | disk | FTP | other *** search
-
- { EASY-WRITE v. 1.0
- ~~~~~~~~~~~~~~~~~~
-
-
- Note: This editor is donated to the "public domain". You can make illimited
- ~~~~
- copies of it.
-
- However, if you modify it to better suit your tastes, I would appreciate
-
- that you mention it before distributing the modified version.
-
- Feel free to send me your comments, good or bad.
-
- This program has been written with Turbo Pascal v. 3.01a.
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- Guy Lachance,
-
- [71460,3407].
-
- last revision : 87/12/10
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- }
-
-
- PROGRAM EasyWrite (input,output);
-
- {$R+}
-
- CONST (* max number of lines of the document *)
- maxline=2000; (* you can change it, but it will slow down *)
- (* some commands, namely Ctrl-N and Ctrl-L *)
- TYPE
- string80=string[80];
- linepointer=^lineOftext;
- Lineoftext=string80;
-
- VAR
- worksheet:array[1..maxline] of LinePointer;
- WaitForRetrace:boolean;
- BaseOfScreen:Integer;
- x,y,z:integer;
- blankString:string80;
- bkstrindex:integer;
- wcActive,loadflag,firstime:boolean;
- wcnoli:integer;
- edmode:(ist,overwrite);
-
- (* EgaInstalled, GetVideoMode and FastwriteNA are from Brian Foley
- [76317,3247] Thanks Brian ! *)
-
- FUNCTION EgaInstalled : Boolean;
- {-Test for presence of the EGA. I have little idea how this works, but
- it does.}
- BEGIN
- Inline(
- $B8/$00/$12 { MOV AX,$1200}
- /$BB/$10/$00 { MOV BX,$10}
- /$B9/$FF/$FF { MOV CX,$FFFF}
- /$CD/$10 { INT $10}
- /$31/$C0 { XOR AX,AX}
- /$81/$F9/$FF/$FF { CMP CX,$FFFF}
- /$74/$01 { JE DONE}
- /$40 { INC AX}
- /$88/$46/$04 {DONE: MOV [BP+$04],AL}
- );
- END;
-
- PROCEDURE GetVideoMode;
- {-Video mode of 7 indicates mono display; all other modes are for color
- displays. This routine MUST be called before any of the screen writing
- routines are used!}
- VAR
- Mode : Integer;
- BEGIN
- Inline(
- $B4/$0F {MOV AH,$F}
- /$CD/$10 {INT $10}
- /$30/$E4 {XOR AH,AH}
- /$89/$46/<Mode {MOV [BP+<Mode],AX}
- );
- IF Mode = 7 THEN BaseOfScreen := $B000 { Mono }
- ELSE BaseOfScreen := $B800; { Color }
- WaitForRetrace := (BaseOfScreen = $B800) And Not EgaInstalled;
- { If WaitForRetrace is True, you may want to allow the user to decide
- whether to forego snow prevention in favor of faster screen updates.
- *VERY IMPORTANT* WaitForRetrace MUST be false if BaseOfScreen = $B000. }
- END;
-
- PROCEDURE FastWriteNA( St : String80; Row, Col : Byte );
- {-Same as FastWrite, but no attribute byte paramater. String appears
- in whatever attribute(s) was/were there to begin with.}
- BEGIN
- Inline(
- $8C/$DB { MOV BX,DS ;Save DS in BX}
- /$31/$C0 { XOR AX,AX}
- /$88/$C1 { MOV CL,AL}
- /$8A/$AE/>Row { MOV CH,[BP+>Row]}
- /$FE/$CD { DEC CH}
- /$D1/$E9 { SHR CX,1}
- /$89/$CF { MOV DI,CX}
- /$D1/$EF { SHR DI,1}
- /$D1/$EF { SHR DI,1}
- /$01/$CF { ADD DI,CX}
- /$8B/$8E/>Col { MOV CX,[BP+>Col]}
- /$49 { DEC CX}
- /$D1/$E1 { SHL CX,1}
- /$01/$CF { ADD DI,CX}
- /$8E/$06/>BaseOfScreen { MOV ES,[>BaseOfScreen]}
- /$8A/$0E/>WaitForRetrace{ MOV CL,[>WaitForRetrace]}
- /$8C/$D2 { MOV DX,SS}
- /$8E/$DA { MOV DS,DX}
- /$8D/$B6/>St { LEA SI,[BP+>St]}
- /$FC { CLD}
- /$AC { LODSB}
- /$91 { XCHG AX,CX}
- /$E3/$26 { JCXZ Exit}
- /$D0/$D8 { RCR AL,1}
- /$73/$1E { JNC NoWait}
- /$BA/$DA/$03 { MOV DX,$03DA}
- /$AC {Next: LODSB}
- /$88/$C4 { MOV AH,AL ;Store char in AH}
- /$FA { CLI}
- /$EC {WaitNoH: IN AL,DX}
- /$A8/$08 { TEST AL,8}
- /$75/$09 { JNZ Store}
- /$D0/$D8 { RCR AL,1}
- /$72/$F7 { JC WaitNoH}
- /$EC {WaitH: IN AL,DX}
- /$D0/$D8 { RCR AL,1}
- /$73/$FB { JNC WaitH}
- /$88/$E0 {Store: MOV AL,AH ;Move char back to AL...}
- /$AA { STOSB ; and then to screen}
- /$FB { STI}
- /$47 { INC DI}
- /$E2/$E7 { LOOP Next}
- /$EB/$04 { JMP SHORT Exit}
- /$A4 {NoWait: MOVSB ;Move character to screen}
- /$47 { INC DI ;Skip attribute bytes}
- /$E2/$FC { LOOP NoWait}
- /$8E/$DB {Exit: MOV DS,BX ;Restore DS from BX}
- );
- END;
-
-
- PROCEDURE ChangeCursor(CursorType:integer);
-
- (*
- CursorType of 1 : change cursor to normal
- " " " 2 : change cursor to a box
- *)
-
- var
- start,stop : byte;
- Regs: RECORD
- CASE integer of
- 0: (ax,bx,cx,dx,bp,si,di,ds,es,flags : integer);
- 1: (al,ah,bl,bh,cl,ch,dl,dh : byte)
- END;
-
- begin (* of procedure ChangeCursor *)
-
- CASE cursorType of
- 1: begin
- start:=11;
- stop:=12;
- end;
- 2: begin
- start:=2;
- stop:=12;
- end;
- END;
- WITH Regs DO
- begin
- ax:=$0100;
- ch:=Start;
- cl:=Stop;
- Intr($10,Regs);
- end;
-
- end; (* of procedure changeCursor *)
-
-
- PROCEDURE DLWC; (* procedure to Determine the Length of the Working Copy *)
- var (* "wcnoli" becomes the number of the last line *)
- i:integer; (* if it is 0 then it means that the Working Copy is empty *)
- begin
- i:=maxline+1;
- REPEAT
- i:=i-1;
- UNTIL ((length(worksheet[i]^)<>0) or (i=1));
- wcnoli:=i;
- if ((wcnoli=1) and (length(worksheet[1]^)=0)) then wcnoli:=0;
- end;
-
-
- PROCEDURE initialize;
- var
- k,i:integer;
- p:linepointer;
- begin
- x:=1; y:=1; z:=1;
- wcnoli:=0;
- wcActive:=false;
- loadflag:=false;
- for k:=1 to maxline do
- begin
- if firstime then
- begin
- new(p);
- Worksheet[k]:=p;
- end;
- Worksheet[k]^:=blankString;
- Worksheet[k]^[0]:=chr(0);
- end;
- end; (* of initialize *)
-
- PROCEDURE Load;
-
- type
- string20=string[20];
- string137=string[137];
-
- var
- index,j:integer;
- Textfile:text;
- filename:string20;
- scratch:string137;
- cf,choice:char;
-
- begin (* of procedure load *)
- clrscr;
- gotoxy(35,25);
- lowvideo;
- write('LOAD FILE');
- normvideo;
- gotoxy(5,5);
- write('Enter filename : ');
- readln(filename);
- (* filename:='b:\'+filename; *) { remove the comments if you }
- assign(Textfile,filename); { want easy-write to load from }
- {$I-} { drive b: }
- reset(Textfile);
- {$I+}
- If IOresult <> 0 then
- begin
- writeln; writeln;
- gotoxy(5,wherey);
- writeln('PROBLEM... Cannot find ',filename);
- write(chr(7));
- writeln;
- writeln;
- gotoxy(5,wherey);
- write('Press <──┘ to continue');
- readln;
-
- end
- ELSE
- BEGIN
- choice:='n';
- if wcActive then
- begin
- writeln;
- gotoxy(5,wherey);
- writeln('WARNING !! You are about to overwrite the Working Copy...');
- writeln;
- gotoxy(5,wherey);
- write('Do you want to continue ? (y/n) : ');
- readln(choice);
- end;
- if (not wcActive) or (choice in ['y','Y']) then (* proceed *)
- begin
- x:=1; y:=1; z:=1;
- index:=1;
- writeln;
- gotoxy(5,wherey);
- write('Loading ',filename,'... Please Wait.');
- if ((wcActive) or (loadflag)) then initialize;
- WHILE ((NOT EOF(Textfile)) and (index <= maxline)) DO
- begin
- readln(Textfile,scratch);
- worksheet[index]^:=scratch;
- index:=index+1;
- end;
- DLWC;
- loadflag:=true;
- close(textfile);
- if index > maxline then
- begin
- writeln; writeln;
- gotoxy(5,wherey);
- writeln('WARNING : The file is too big. It has NOT been loaded entirely.');
- writeln;
- gotoxy(5,wherey);
- write('Press <──┘ to continue');
- readln;
- end;
- end;
- END;
-
- end; (* of the procedure load *)
-
- PROCEDURE Save;
- label
- saveError;
- type
- string20=string[20];
- var
- Textfile:text;
- filename:string20;
- i:integer;
-
- begin (* of procedure save *)
- clrscr;
- lowvideo;
- gotoxy(31,25);
- write('SAVE WORKING COPY');
- normvideo;
- IF wcnoli <> 0 then
- begin (* save *)
- gotoxy(5,5);
- write('Enter filename : ');
- readln(filename);
- (* filename:='b:\'+filename; *) { remove the comments if }
- assign(Textfile,filename); { you want easy-write to }
- {$I-} { save to drive b: }
- rewrite(Textfile);
- {$I+}
- if IOresult <> 0 then goto saveError;
- gotoxy(5,7);
- write('Saving ',filename,'... Please wait.');
- for i:=1 to wcnoli do
- writeln(Textfile,worksheet[i]^);
- close(Textfile);
- wcActive:=false;
- loadflag:=true;
- end
- ELSE
- begin
- gotoxy(5,5);
- write('ERROR : The Working Copy is empty.');
- gotoxy(5,7);
- write('Press <──┘ to continue');
- readln;
- end;
-
- if 1=2 then
- saveError:
- begin
- gotoxy(5,7);
- write('ERROR : You have to give a name.');
- gotoxy(5,9);
- write('Press <──┘ to continue');
- readln;
- end;
-
- end; (* of procedure save *)
-
- PROCEDURE Print;
- var
- printerSelection:char;
- style:char;
- lineCounter:integer;
- doubleSpace:char;
- i,j:integer;
- top,bottom,pl:integer;
-
- function PrinterOK:boolean; (* test if printer is ready *)
- var
- Regs:RECORD
- AX,BX,CX,DX,BP,SI,DI,DS,ES,FLAGS:integer;
- END;
- begin
- Regs.DX:=$0000;
- Regs.AX:=$0100;
- Intr($17,Regs);
- PrinterOK:=(NOT(Odd(Regs.AX Shr 11))) AND (NOT(Odd(Regs.AX Shr 13)));
- end;
-
- begin (* procedure print *)
- clrscr;
- lowvideo;
- gotoxy(31,25);
- write('PRINT WORKING COPY');
- normvideo;
- if wcnoli <> 0 then
- begin
- gotoxy(5,5);
- write('1'); lowvideo; write(') Star SG-10 '); normvideo;
- write('2'); lowvideo; write(') IBM Pro Printer '); normvideo;
- write('3'); lowvideo; write(') CANCEL PRINTING '); normvideo;
- gotoxy(5,9);
- write('Enter selection : ');
- readln(printerSelection);
- if not(printerSelection in ['1'..'3']) then
- repeat
- gotoxy(5,9);
- write('Enter selection : ');
- clreol;
- readln(printerSelection);
- until printerSelection in ['1'..'3'];
- if printerSelection <> '3' then
- begin
- if not printerok then
- repeat
- gotoxy(5,11);
- write('PROBLEM : The printer is not ready.');
- gotoxy(5,13);
- write('Make it READY and then press <──┘ to continue');
- readln;
- until printerok;
- gotoxy(5,11); clreol; gotoxy(5,13); clreol;
- gotoxy(5,11);
- write('Do you want to print in NLQ ? (y/n) : ');
- readln(style);
- if style in ['y','Y'] then
- case printerselection of
- '1' : write(lst,chr(27),chr(52));
- '2' : write(lst,chr(27),chr(71));
- end;
- gotoxy(5,13);
- write('Do you want to print in double-space ? (y/n) : ');
- readln(doubleSpace);
- gotoxy(5,15);
- write(' Enter top margin : ');
- readln(top);
- gotoxy(5,17);
- write('Enter bottom margin : ');
- readln(bottom);
- gotoxy(5,19);
- write(' Enter page length : ');
- readln(pl);
- gotoxy(5,21);
- write('Printing...Please wait.');
- for j:=1 to top do write(lst,chr(10));
- lineCounter:=0;
- for i:=1 to wcnoli do
- begin
- writeln(lst,worksheet[i]^);
- lineCounter:=lineCounter+1;
- if lineCounter=(pl-top-bottom) then
- begin
- write(lst,chr(12));
- for j:=1 to top do write(lst,chr(10));
- lineCounter:=0;
- end;
- if doublespace in ['y','Y'] then
- begin
- write(lst,chr(10));
- lineCounter:=lineCounter+1;
- end;
- if lineCounter=(pl-top-bottom) then
- begin
- write(lst,chr(12));
- for j:=1 to top do write(lst,chr(10));
- lineCounter:=0;
- end;
- end;
- case printerselection of
- '1': write(lst,chr(27),chr(53));
- '2': write(lst,chr(27),chr(72));
- end;
- write(lst,chr(12));
- delay(5000);
- end;
- end
- else
- begin
- gotoxy(5,5);
- write('ERROR : The working copy is empty.');
- gotoxy(5,7);
- write('Press <──┘ to continue');
- readln;
- end;
-
-
- end; (* procedure print *)
-
- PROCEDURE Erase;
- var
- choice:char;
- begin
- clrscr;
- lowvideo;
- gotoxy(31,25);
- write('ERASE WORKING COPY');
- normvideo;
- choice:='n';
- if wcActive then
- begin
- gotoxy(5,5);
- write('WARNING !! You are about to erase the working copy.');
- gotoxy(5,7);
- write('Your changes have NOT been saved.');
- gotoxy(5,9);
- write('Do you want to continue ? (y/n) : ');
- readln(choice);
- end;
- if (not wcActive) or (choice in ['y','Y']) then (* proceed *)
- begin
- if wcActive then gotoxy(5,11)
- else gotoxy(5,5);
- write('Erasing the WORKING COPY. Please wait... ');
- initialize;
- end;
- end; (* of procedure erase *)
-
-
- PROCEDURE EDIT;
- var
-
- ch:char;
- i,j,k,m:integer;
- escape,updatey:boolean;
- u,d,e,t:integer;
- aiv:integer;
-
- procedure refresh(start:integer);
- var
- b:byte;
- q:integer;
- begin
- if edmode=ist then
- fastwriteNA('Esc : Main menu Mode : Insert Line : 1 Column : 1',1,1)
- else
- fastwriteNA('Esc : Main menu Mode : Overwrite Line : 1 Column : 1',1,1);
- fastwriteNA('────────────────────────────────────────────────────────────────────────────────',2,1);
- fastwriteNA('┴┴┴┴┼┴┴┴┴1┴┴┴┴┼┴┴┴┴2┴┴┴┴┼┴┴┴┴3┴┴┴┴┼┴┴┴┴4┴┴┴┴┼┴┴┴┴5┴┴┴┴┼┴┴┴┴6┴┴┴┴┼┴┴┴┴7┴┴┴┴┼┴┴┴┴',25,1);
- q:=start;
- window(1,1,80,25);
- gotoxy(59,1);
- write(' ');
- gotoxy(59,1);
- write(z);
- gotoxy(76,1);
- write(' ');
- gotoxy(76,1);
- write(x);
- window(1,3,80,24);
- for b:=3 to 24 do
- begin
- fastwriteNA(' ',b,1);
- fastwriteNA(worksheet[q]^,b,1);
- q:=q+1;
- end;
- end; (* of procedure refresh *)
-
- begin (* of procedure EDIT *)
- clrscr;
- if edmode=ist then changeCursor(2);
- window(1,3,80,24);
- refresh(z-y+1);
- gotoxy(x,y);
- REPEAT
- ch:=chr(1);
- escape:=false;
- if keypressed then
- begin
- read(kbd,ch);
- if (ch=#27) and keypressed then
- begin
- escape:=true;
- read(kbd,ch);
- end;
- end;
- if escape then (* escape codes *)
- begin
- case ord(ch) of
- 75:if x>1 then (* left arrow key *)
- begin
- gotoxy(wherex-1,wherey);
- x:=x-1;
- window(1,1,80,25);
- gotoxy(76,1);
- write(' ');
- gotoxy(76,1);
- write(x);
- window(1,3,80,24);
- gotoxy(x,y);
- end;
- 77:if ((x<=80) and (not((x=80) and (z=maxline)))) then
- begin (* right arrow key *)
- updatey:=false;
- gotoxy(wherex+1,wherey);
- x:=x+1;
- if ((x>80) and (z < maxline)) then
- begin
- if wherey=22 then
- begin
- z:=z+1; x:=1;
- refresh(z-21);
- gotoxy(x,22);
- updatey:=true;
- end
- else
- begin
- x:=1; y:=y+1; z:=z+1;
- updatey:=true;
- end;
- end;
- window(1,1,80,25);
- gotoxy(76,1);
- write(' ');
- gotoxy(76,1);
- write(x);
- if updatey then
- begin
- gotoxy(59,1);
- write(' ');
- gotoxy(59,1);
- write(z);
- end;
- window(1,3,80,24);
- gotoxy(x,y);
- end;
- 72:if y>1 then (* up arrow key *)
-
- begin
- gotoxy(wherex,wherey-1);
- y:=y-1; z:=z-1;
- window(1,1,80,25);
- gotoxy(59,1);
- write(' ');
- gotoxy(59,1);
- write(z);
- window(1,3,80,24);
- gotoxy(x,y);
- end
-
- else
-
- if ((wherey=1) and (z<>1)) then
- begin
- z:=z-1;
- refresh(z);
- gotoxy(x,1);
- end;
-
- 80:if z<maxline then (* down arrow key *)
- if wherey=22 then
- begin
- z:=z+1;
- refresh(z-21);
- gotoxy(x,22);
- end
- else
- begin
- gotoxy(wherex,wherey+1);
- y:=y+1;
- z:=z+1;
- window(1,1,80,25);
- gotoxy(59,1);
- write(' ');
- gotoxy(59,1);
- write(z);
- window(1,3,80,24);
- gotoxy(x,y);
- end;
- 71:if x>1 then (* home key *)
- begin
- gotoxy(1,wherey);
- x:=1;
- window(1,1,80,25);
- gotoxy(76,1);
- write(' ');
- gotoxy(76,1);
- write(x);
- window(1,3,80,24);
- gotoxy(x,y);
- end;
- (* end key *)
- 79: begin
- if length(worksheet[z]^) < 80 then
- begin
- gotoxy((length(worksheet[z]^)+1),wherey);
- x:=(length(worksheet[z]^))+1;
- end
- else
- begin
- gotoxy((length(worksheet[z]^)),wherey);
- x:=(length(worksheet[z]^));
- end;
- window(1,1,80,25);
- gotoxy(76,1);
- write(' ');
- gotoxy(76,1);
- write(x);
- window(1,3,80,24);
- gotoxy(x,y);
- end;
-
- 82: begin (* insert/overwrite toggle *)
- if (edmode=ist) then
- begin
- edmode:=overwrite;
- changeCursor(1);
- end
- else
- begin
- edmode:=ist;
- changeCursor(2);
- end;
- refresh(z-y+1);
- gotoxy(x,y);
- end;
-
- 132: begin (* Ctrl-PgUp : to top of working copy *)
- x:=1; y:=1; z:=1;
- refresh(1);
- gotoxy(1,1);
- end;
-
- 118: begin (* Ctrl-PgDn : to end of working copy *)
- if wcnoli > 0 then z:=wcnoli else z:=1;
- if wcnoli > 0 then
- m:=length(worksheet[wcnoli]^) else m:=0;
- if m=80 then x:=m else x:=m+1;
- if wcnoli < 23 then
- begin
- if wcnoli > 0 then y:=wcnoli else y:=1;
- refresh(1);
- end
- else
- begin
- y:=22;
- refresh(z-21);
- end;
- gotoxy(x,y);
- end;
-
- 83: if x <= length(worksheet[z]^) then (* del key *)
- begin
- wcActive:=true;
- delete(worksheet[z]^,x,1);
- refresh(z-y+1);
- gotoxy(x,y);
- end;
-
- end; (* of the case statement *)
-
- end
- else (* non escape codes *)
- if not (ch in [chr(32)..chr(255)]) then
- begin
- case ord(ch) of
- 13: if z<maxline then (* return key *)
- case edmode of
- OVERWRITE:
- begin (* with auto-indent *)
- j:=0;
- if length(worksheet[z]^) = 0 then
- aiv:=1
- else
- begin
- repeat
- j:=j+1;
- until ((worksheet[z]^[j] <> ' ') or (j=80));
- aiv:=j;
- end;
- if wherey=22 then
- begin
- z:=z+1; x:=aiv;
- refresh(z-21);
- gotoxy(x,22);
- end
- else
- begin
- x:=aiv;
- y:=y+1; z:=z+1;
- window(1,1,80,25);
- gotoxy(59,1);
- write(' ');
- gotoxy(59,1);
- write(y);
- gotoxy(76,1);
- write(' ');
- gotoxy(76,1);
- write(x);
- window(1,3,80,24);
- gotoxy(x,y);
- end;
- end;
-
- IST: begin
- wcActive:=true;
- if length(worksheet[z]^) = 0 then
- aiv:=1
- else
- begin
- j:=0;
- repeat
- j:=j+1;
- until ((worksheet[z]^[j] <> ' ') or (j=80));
- aiv:=j;
- end;
- x:=aiv; z:=z+1;
- if wherey < 22 then y:=y+1;
- for k:=wcnoli downto z do
- begin
- worksheet[k+1]^:=blankString;
- worksheet[k+1]^:=worksheet[k]^;
- end;
- worksheet[z]^:=blankString;
- worksheet[z]^[0]:=chr(0);
- wcnoli:=wcnoli+1;
- refresh(z-y+1);
- gotoxy(x,y);
- end;
- end; (* of the case statement *)
-
- 12: if (wcnoli > 0) and (z <= wcnoli) then
- begin (* Ctrl-L : delete a line *)
- wcActive:=true;
- for k:=(z+1) to wcnoli do
- begin
- worksheet[k-1]^:=blankString;
- worksheet[k-1]^:=worksheet[k]^;
- end;
- worksheet[wcnoli]^:=blankString;
- worksheet[wcnoli]^[0]:=chr(0);
- wcnoli:=wcnoli-1;
- refresh(z-y+1);
- gotoxy(x,y);
- end;
-
- 14: if wcnoli < maxline then
- begin (* Ctrl-N : insert a blank line *)
- wcActive:=true;
- for k:=wcnoli downto z do
- begin
- worksheet[k+1]^:=blankString;
- worksheet[k+1]^:=worksheet[k]^;
- end;
- worksheet[z]^:=blankString;
- worksheet[z]^[0]:=chr(0);
- wcnoli:=wcnoli+1;
- refresh(z-y+1);
- gotoxy(x,y);
- end;
-
- 8: if x>1 then (* backspace key *)
- begin
- wcActive:=true;
- gotoxy(wherex-1,wherey);
- x:=x-1;
- delete(worksheet[z]^,x,1);
- refresh(z-y+1);
- gotoxy(x,y);
- end;
- end;
- end
- else (* write a char to the screen and in the array *)
- CASE edmode of
-
- OVERWRITE:
-
- begin
- write(ch); wcActive:=true;
- x:=x+1;
- if ((x>80) and (z < maxline)) then
- begin
- if wherey=22 then
- begin
- z:=z+1; x:=1;
- refresh(z-21);
- gotoxy(1,22);
- end
- else
- begin
- x:=1; y:=y+1; z:=z+1;
- end;
- end;
- if ((x > 80) and (z=maxline)) then x:=1; (* if reached the end of the working copy *)
- window(1,1,80,25);
- gotoxy(76,1);
- write(' ');
- gotoxy(76,1);
- write(x);
- gotoxy(59,1);
- write(' ');
- gotoxy(59,1);
- write(z);
- window(1,3,80,24);
- gotoxy(x,y);
- if x=1 then
- begin
- u:=80;
- if z=maxline then t:=z else t:=z-1;
- end
- else
- begin
- u:=x-1;
- t:=z;
- end;
- Worksheet[t]^[u]:=ch;
- if ((ch<>' ') and (z > wcnoli)) then wcnoli:=z;
- if ((u > length(worksheet[t]^)) and (ch <> ' ')) then worksheet[t]^[0]:=chr(u);
- end;
-
- IST:
-
- begin
- wcActive:=true;
- if x < 80 then
- begin
- if x > length(worksheet[z]^) then
- begin
- write(ch);
- worksheet[z]^[x]:=ch;
- if ch <> ' ' then
- begin
- worksheet[z]^[0]:=chr(x);
- if z > wcnoli then wcnoli:=z;
- end;
- x:=x+1;
- window(1,1,80,25);
- gotoxy(76,1);
- write(' ');
- gotoxy(76,1);
- write(x);
- window(1,3,80,24);
- gotoxy(x,y);
- end
- else
- begin
- insert(ch,worksheet[z]^,x);
- x:=x+1;
- refresh(z-y+1);
- gotoxy(x,y);
- end;
- end
- else if ((wcnoli < maxline) and (z < maxline)) then (* x=80 *)
- begin
- write(ch);
- worksheet[z]^[80]:=ch;
- worksheet[z]^[0]:=chr(80);
- j:=0;
- repeat
- j:=j+1;
- until ((worksheet[z]^[j] <> ' ') or (j=80));
- aiv:=j;
- x:=aiv; z:=z+1;
- if wherey < 22 then y:=y+1;
- for k:=wcnoli downto z do
- begin
- worksheet[k+1]^:=blankString;
- worksheet[k+1]^:=worksheet[k]^;
- end;
- worksheet[z]^:=blankString;
- worksheet[z]^[0]:=chr(0);
- wcnoli:=wcnoli+1;
- refresh(z-y+1);
- gotoxy(x,y);
- end; (* else if wcnoli < maxline then ( x = 80 ) *)
- end; (* of the insert section *)
- end; (* of the CASE edmode of.... *)
-
-
- UNTIL ord(ch)=27;
-
- end; (* of procedure edit *)
-
-
-
- PROCEDURE MainMenu;
- const
- tab=30;
- var
- MainChoice,exitChoice:char;
- begin
- MainChoice:='1';
- REPEAT
- window(1,1,80,25);
- changeCursor(1);
- Clrscr;
- gotoxy(tab-7,1);
- writeln('<<<<<<< MAIN MENU >>>>>>>');
- gotoxy(tab,6);
- write('1'); lowvideo; write(') Edit/Create'); Normvideo;
- gotoxy(tab,8);
- write('2'); lowvideo; write(') Load file'); Normvideo;
- gotoxy(tab,10);
- write('3'); lowvideo; write(') Save working copy'); Normvideo;
- gotoxy(tab,12);
- write('4'); lowvideo; write(') Print working copy'); NormVideo;
- gotoxy(tab,14);
- write('5'); lowvideo; write(') Erase working copy'); normvideo;
- gotoxy(tab,16);
- write('6'); lowvideo; write(') Exit');
- if firstime then begin
- gotoxy(1,25); write('(c) EASY-WRITE ( program by Guy Lachance )');
- end;
- gotoxy(tab,20);
- write('Enter choice ('); normvideo; write('1-6'); lowvideo; write(') : ');
- normvideo;
- readln(MainChoice);
- if ((Mainchoice >= '1') and (Mainchoice <= '6')) then
- begin
- firstime:=false;
- case Mainchoice of
- '1':edit;
- '2':load;
- '3':save;
- '4':print;
- '5':erase;
- '6':if ((wcActive) and (wcnoli <> 0)) then
- begin
- clrscr;
- gotoxy(5,5);
- write('WARNING !! Your changes have not been saved !');
- lowvideo;
- gotoxy(38,25);
- write('EXIT');
- normvideo;
- gotoxy(5,7);
- exitChoice:='n';
- write('Do you want to continue ? (y/n) : ');
- read(exitChoice);
- if (not(exitChoice in ['y','Y'])) then MainChoice:='1';
- end;
- end;
- end;
- UNTIL MainChoice='6';
- end; (* of the procedure MainMenu *)
-
-
-
-
- BEGIN (* main program *)
-
- firstime:=true;
- edmode:=ist;
- getVideoMode;
- clrscr;
- gotoxy(25,12);
- write(' One moment please... ');
- blankString:='';
- for bkstrindex:=1 to 80 do
- blankString:=blankString+' ';
- initialize;
- mainmenu; (* go for it ! start the program ! *)
- clrscr;
-
- END. (* main program *)